package com.hsy.directseeding.common;

import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;


import com.deparse.dpframe.ui.fragment.DPBaseFragment;

import java.io.File;


/**
 * Created by hsy on 2016/3/23.
 */
public abstract class CommonBaseFragment extends DPBaseFragment {

    /**
     * Fragment当前状态是否可见
     */
    protected boolean isVisible;


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);

        if (getUserVisibleHint()) {
            isVisible = true;
            onVisible();
        } else {
            isVisible = false;
            onInvisible();
        }
    }


    /**
     * 可见
     */
    protected void onVisible() {
//        onFragmentUpdate();
    }

    /**
     * 不可见
     */
    protected void onInvisible() {

    }

    @Override
    public void onResume() {
        super.onResume();
//        JPushInterface.onFragmentResume(getAttchedActivity(),null);
    }

    @Override
    public void onPause() {
        super.onPause();
//        JPushInterface.onFragmentPause(getAttchedActivity(),null);
    }

    @Override
    public void onDestroyView() {
//        File cacheDir = new File(DPFileUtil.getCacheDir(getContext()));
//        if (cacheDir.exists() && cacheDir.isDirectory()) {
//            DPFileUtil.emptyDir(cacheDir);
//        }
//        super.onDestroyView();
//        System.gc();
        super.onDestroyView();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }


}
